#! /usr/bin/env python
# Author: Diana Godfrey

PKG = 'languagememory'
import sys
from collections import defaultdict

class Noun(dict):

	def __init__(self, newname, default=None):
		self.default = default
		self.myname = newname
		self.objects = defaultdict(dict)

	def printNoun(self):
		print self.getName()

	def getName(self):
		return self.myname

	def printObjects(self, noun=None):
            if noun is None:
                print "\n%s:" %self.getName()
                for k in self.objects:
                    print k
                    for item in self.objects[k]:
                        print ":%s"%item
            else:
                if noun in self.objects:
                    print "\n%s:" %noun
                    for v in self.objects[noun]:
                        print v

                else:
                    print "I don't really know anything that's a %s." %noun

	def addObj(self, word, kind=None):
            if kind is None:
                if word not in self.objects:
                    self.objects[word] = []
            else:
                if kind in self.objects:
                    if word not in self.objects[kind]:
                        self.objects[kind].append(word)
                    else:
                        self.objects[kind].append([word])
                else:
                    self.objects[kind] = [word]

if __name__ == '__main__':
	blue = Noun("blue")
	car = Noun("car")
	radio = Noun("radio")
	blue.addObj("car")
	blue.addObj("radio")
	red = Noun("red")
	red.addObj("cherry")
        red.addObj("apple")
	blue.addObj("sea", "aqua")
        blue.addObj("stone", "aqua")
        blue.addObj("car", "aqua")
#	blue.printObjects("aqua")
        blue.printObjects()
	red.printObjects()

#	car = Noun(dict)
#	car.addObj("Ford", "Mustang")
#        car.addObj("Mustang", "4-door")
#        #WRITE ADDCHAR
#	car.addObj("Ford", "Taurus")
#	car.addObj("Toyota", "Corolla")
##	print car_details
#        car.printObjects('Mustang')
#        car.printObjects("Toyota")
        #WRITE GETITEMS
#	onedim = Noun(dict)
#	onedim['Toyota'] = "blue"
#	print onedim
#	twodim = Noun( lambda: Noun( list ) )
#	twodim['Toyota']['Camry'] = "blue"
#	print twodim
#	threedim = Noun( lambda: Noun( lambda: Noun( list ) ) )
#	threedim['Camry']['Diana']['Toyota'] = "blue"
#	print threedim
